package com.itany.corejava.code06_数组;

import java.util.Arrays;

/**
 * @author 石小俊
 * @date 2023年04月12日 16:49
 */
public class Test05_Arrays工具类 {
    public static void main(String[] args) {
//        toStringTest();
        sortTest();
    }

    public static void toStringTest() {
        int[] nums = {1, 3, 6, 9, 12};
        System.out.println("[" + nums[0] + ", " + nums[1] + ", " + nums[2] + ", " + nums[3] + ", " + nums[4] + "]");
        // 返回的数据格式: [元素1,元素2,...元素n]
        System.out.println(Arrays.toString(nums));
    }

    public static void sortTest() {
        int[] nums = {5, 3, 7, 1, 2, 8, 12, 32, 23, 9};
        // 根据值的大小进行升序排序
        // 将排序后的结果赋值给原数组
        Arrays.sort(nums);
        System.out.println(Arrays.toString(nums));

        String[] numbers = {"6", "2", "1", "3", "11", "12", "21", "22"};
        Arrays.sort(numbers);
        System.out.println(Arrays.toString(numbers));

        String[] names = {"alice", "jack", "tom", "admin", "lily"};
        Arrays.sort(names);
        System.out.println(Arrays.toString(names));
    }

}
